import Vue from 'vue';
import { set } from 'vue/types/umd';
import Vuex, { Store } from 'vuex';

Vue.use(Vuex);

export default new Store({
  state() {
    return {
      // 监测设备
      equipment: {},
      tester: '',
      result: [],
      history: [],
      imagePreviewCloseFn: null,
      showPane: false,
      // 搜索选中的变电站
      station: {}
    };
  },
  mutations: {
    setEquipment(state, equipment) {
      state.equipment = equipment;
    },
    setTester(state, tester) {
      state.tester = tester;
    },
    setResult(state, result) {
      state.result = result;
    },
    setHistory(state, history) {
      state.history = history;
    },
    setImagePreviewCloseFn(state, imagePreviewCloseFn) {
      state.imagePreviewCloseFn = imagePreviewCloseFn;
    },
    setShowPane(state, showPane) {
      state.showPane = showPane;
    },
    setStation(state, station) {
      state.station = station;
    }
  },
  actions: {
    setEquipment({ commit }, equipment) {
      commit('setEquipment', equipment);
    },
    setTester({ commit }, tester) {
      commit('setTester', tester);
    },
    setResult({ commit }, result) {
      commit('setResult', result);
    },
    setHistory({ commit }, history) {
      commit('setHistory', history);
    },
    setImagePreviewCloseFn({ commit }, imagePreviewCloseFn) {
      commit('setImagePreviewCloseFn', imagePreviewCloseFn);
    },
    setShowPane({ commit }, showPane) {
      commit('setShowPane', showPane);
    },
    setStation({ commit }, station) {
      commit('setStation', station);
    }
  }
});
